﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.Storage;

namespace launcher.Services
{
    static class SettingKey
    {
        public const string LastExecutableFile = "LastExecutableFile";
        public const string LastTextFilter = "LastTextFilter";
        public const string LastRegexFilter = "LastRegexFilter";
        public const string HistoryExecutableFiles = "HistoryExecutableFiles";
        public const string HistoryTextFilters = "HistoryTextFilters";
        public const string HistoryRegexFilters = "HistoryRegexFilters";
        public const string KillProcessWhenStop = "KillProcessWhenStop";
    }

    internal class LocalSettings
    {
        private readonly ApplicationDataContainer m_localSettings = ApplicationData.Current.LocalSettings;

        /// <summary>
        /// 最后设置的用户应用程序（可执行文件）路径
        /// </summary>
        public string LastExecutableFile
        {
            get => m_localSettings.Values[SettingKey.LastExecutableFile] as string;
            set => m_localSettings.Values[SettingKey.LastExecutableFile] = value;
        }

        /// <summary>
        /// 最后设置的文本过滤器
        /// </summary>
        public string LastTextFilter
        {
            get => m_localSettings.Values[SettingKey.LastTextFilter] as string;
            set => m_localSettings.Values[SettingKey.LastTextFilter] = value;
        }

        /// <summary>
        /// 最后设置的正则表达式过滤器
        /// </summary>
        public string LastRegexFilter
        {
            get => m_localSettings.Values[SettingKey.LastRegexFilter] as string;
            set => m_localSettings.Values[SettingKey.LastRegexFilter] = value;
        }

        public string[] HistroryTextFilters
        {
            get => m_localSettings.Values[SettingKey.HistoryTextFilters] as string[];
            set => m_localSettings.Values[SettingKey.HistoryTextFilters] = value;
        }

        public string[] HistoryRegexFilters
        {
            get => m_localSettings.Values[SettingKey.HistoryRegexFilters] as string[];
            set => m_localSettings.Values[SettingKey.HistoryRegexFilters] = value;
        }

        public string[] HistoryExecutableFiles
        {
            get => m_localSettings.Values[SettingKey.HistoryExecutableFiles] as string[];
            set => m_localSettings.Values[SettingKey.HistoryExecutableFiles] = value;
        }

        public bool? KillProcessWhenStop
        {
            get => m_localSettings.Values[SettingKey.KillProcessWhenStop] as bool?;
            set => m_localSettings.Values[SettingKey.KillProcessWhenStop] = value;
        }
    }
}
